<!DOCTYPE html>
<html>
    <body>
        <a href="https://www.baidu.com">百度</a>
        <form action="https://www.baidu.com">
            <input type="submit" value="提交" name="sub" id="submit">
        </form>
        <script>
            let a = document.querySelector('a')
            let input = document.getElementById('submit')
            a.onclick = function (e) {
                return true
            }
            input.addEventListener('click', function (e) {
                e.preventDefault();
            })
        </script>
    </body>
</html>